package com.complex.spring.advance.aop.base;

import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.NameMatchMethodPointcutAdvisor;

/**
 * 基于类的代理
 * @author gao
 *
 */
public class ProxyFactoryForClass {
	public static void main(String[] args) {
		/**设置目标对象*/
		//织入器 ProxyFactory
		ProxyFactory weaver = new ProxyFactory(new Task());
		//设置advisor
		NameMatchMethodPointcutAdvisor advisor = new NameMatchMethodPointcutAdvisor();
		advisor.setMappedNames(new String[]{"execute"});
		advisor.setAdvice(new PerformanceMethodInterceptor());
		/**设置advisor*/
		weaver.addAdvisor(advisor);
		/**取得代理对象*/		
		Task proxyObject = (Task)weaver.getProxy();
		//调用代理对象
		proxyObject.execute();
		System.out.println(proxyObject.getClass());
	}
}
